<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-用户列表">
</@frame.head>
		<style type="text/css">

             .a-upload {
			    padding: 4px 10px;
			    margin:-8px 1px;
			    height: 20px;
			    line-height: 22px;
			    position: relative;
			    cursor: pointer;
			    color: blue;
			    background: #fafafa;
			    border: none;
			    border-radius: 4px;
			    overflow: hidden;
			    display: inline-block;
			    *display: inline;
			    *zoom: 1;
			}
			
			.a-upload  input {
			    position: absolute;
			    right: 0;
			    top: 0;
			    btttom:0;
			    opacity: 0;
			    filter: alpha(opacity=0);
			    cursor: pointer;
			    width:60px;
			}
			
			.a-upload:hover {
			    color: #444;
			    background: #eee;
			    border-color: #ccc;
			    text-decoration: underline;
			}  
			
			.input_read{
				border:0px;
				text-align: center;
				width:100%;
			} 
			
			.input_write{
				text-align: center;
				width:100%;
			} 
			
			
			td{
				width:100px;
				text-align: center;
			}
			
			.operate_all{
			    width:150px;
			}
			
			.operate_save{
			    width:150px;
			}
			
			a{
			    cursor: pointer;
			}

        </style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 帮助分类管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">


    <div class="cl pd-5 bg-1 bk-gray mt-20"> 
    <span class="r">共有数据：<strong>${helpCategoryList?size}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr  class="text-c">
            <th >帮助分类名称</th>
            <th >分类logo</th>
            <th >帮助信息数</th>
            <th >显示顺序</th>
            <th >状态</th>
            <th >操作</th>
        </tr>
        </thead>
        <body onload="init()">
       <#if helpCategoryList?? && (helpCategoryList?size &gt; 0) >
        <#list helpCategoryList as helpCategory> 
             <tr  class="text-c">
                <td>${helpCategory.name}</td>
                <td>
                <#if helpCategory.logoImage??>
                <img src="${imagePath}/helpCategoryLogo/${helpCategory.id}/${helpCategory.logoImage}" width="50" height="40" id="show${status.index + 1}"/>
                <#else>
				<img  src="" width="50" height="40" id="show${status.index + 1}"/>
                </#if>
                </td>
                <td>${helpCategory.helpInfoList?size}</td>
                <td>${helpCategory.position}</td>
                <td width="55">                                        
                     <#if helpCategory.state=1><span class="label label-success radius">显示</span>
                     <#elseif helpCategory.state=2><span class="label radius">隐藏</span>
                     </#if> 
                </td>
                <td>					
               	<a style="color:blue;" class="edit" onclick="edit(${helpCategory.id})">修改</a> &nbsp;&nbsp;
               	<#if helpCategory.state=1>
               	<a style="color:blue;" onclick="hide(${helpCategory.id})">隐藏</a>&nbsp;&nbsp;	
                <#elseif helpCategory.state=2>
				<a style="color:blue;" onclick="show(${helpCategory.id})">显示</a>&nbsp;&nbsp;	
                </#if> 
               						
              	<a href="javascript:;" class="a-upload"><input type="file" id="uploadlogo${helpCategory_index + 1}"/>上传logo</a>
                </td>
        </tr>
      </#list></#if>
		<div class="clear">
	    </div>
     </body>
    </table>
    <div id="div_page" style="padding-top: 10px;float: right"></div>
</div>
<@frame.end "default">
</@frame.end>
</html>
<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/brand/query_brand.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/ajaxupload.js"></script>
<script type="text/javascript">
var path="${contextPath}";
function edit(id){
	layer_show('修改员工信息',path+'/helpCategory/helpCategory_toedit?id='+id,'450','300');
}

	

function hide(helpCategoryId){
	if(confirm("确定隐藏吗")){
		   var url = path+"/helpCategory/helpCategory_hide";
		   $.ajax({
			   url : url,
		   	   type : "post",
		   	   dataType : "text",
		   	   data : {"id":helpCategoryId},
		   	   success : function(msg){
		   		  if(msg=="success"){
						layer.msg('隐藏成功！',{icon:1,time:1000},function(){
				   			 window.location.href = window.location.href;
						});
		   		  }else{
		   			layer.alert("隐藏失败！");
		   		  }
		   	  },
			  error : function(){
				  layer.alert("操作失败");
			  }
		   });
	   }
}

function show(helpCategoryId){
	if(confirm("确定显示吗")){
		   var url = path+"/helpCategory/helpCategory_show";
		   $.ajax({
			   url : url,
		   	   type : "post",
		   	   dataType : "text",
		   	   data : {"id":helpCategoryId},
		   	   success : function(msg){
		   		  var resultArr = msg.split(",");
		   		  if(resultArr[0]=="success"){
						layer.msg('显示成功！',{icon:1,time:1000},function(){
				   			 window.location.href = window.location.href;
						});

		   		  }else{
		   			layer.alert(resultArr[1]);
		   		  }
		   	  },
			  error : function(){
				  layer.alert("操作失败");
			  }
		   });
	   }
}

function uploadLogo(buttonId,helpCategoryId){

		new AjaxUpload(buttonId, {
			 action: path+'/helpCategory/helpCategory_uploadLogo?id=' + helpCategoryId,
			 dataType: 'text',
		     onSubmit: function(file, ext) {
		    	 
			     if (ext && /^(jpg|png|jpeg|gif|JPG|PNG|JPEG|GIF)$/.test(ext)) {  
			       this.setData({  
			        'key': 'This string will be send with the file'  
			         });  
			      } else {  
				    alert("上传失败！上传图片类型错误，只能上传jpg|gif|jpeg|png类型图片！");
			        return false;  
			      }  
		       }, 
			 onComplete : function(file,response){
				 var response = response.trim();
				 var resultArr = response.split(",");
				 if(resultArr[0] == "fail"){
					 layer.alert("logo上传失败，" + resultArr[1]);
			     }else if(resultArr[0] == "success"){
						layer.msg('logo上传成功',{icon:1,time:1000},function(){
				   			 window.location.href = window.location.href;
						});

			     }else{
			    	 layer.alert("无权限操作;");
			     }
			 }	
		  });	
}
 
//js去掉空格
 function trim(str){ 
	return  str.replace(/^\s+|\s+$/g,"");
 }
 
  function init(){
	  (function($){
          $.fn.extend({
				thumbnail : function(displayExp) {
					return this.each(function(){
	        		var display = $(displayExp);
	       
	        		
	        		
						display.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale) progid:DXImageTransform.Microsoft.BasicImage()");
			        
	
	        		$(this).change(function(){
			        if (this.value) {
				         if ($.browser.msie) {
				          display.get(0).filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = this.value;
				          
				         } else if ($.browser.mozilla)  {
				          if (display.attr("tagName") != "IMG") {
				           var img = $("<img />");
				           
				           img.css({height: display.css("height"), width: display.css("width")});
				           
				           display.replaceWith(img);
				           
				           display = img;
				        }
		          		display.attr('src', window.URL.createObjectURL(this.files.item(0)));
		         		} else {
		          			$(this).unbind("change", arguments.call);
		         		}
	        		}
	       			}).change();
	      		});
     		}
   		});
     })(jQuery);
	
	<#list helpCategoryList as helpCategory> 
	uploadLogo("uploadlogo${helpCategory_index + 1}",${helpCategory.id});
	</#list>
   
   $("#uploadlogo1").thumbnail("#show1");
   $("#uploadlogo2").thumbnail("#show2");
   $("#uploadlogo3").thumbnail("#show3");
   $("#uploadlogo4").thumbnail("#show4");
   $("#uploadlogo5").thumbnail("#show5");

   
};
</script>